
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>简单语法 · Dart编程指南</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="arcticfox">
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="函数.html" />
    
    
    <link rel="prev" href="环境搭建.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://www.bczl.xyz/" target="_blank" class="custom-link">主页</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="基础篇.html">
            
                <a href="基础篇.html">
            
                    
                    基础篇
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="环境搭建.html">
            
                <a href="环境搭建.html">
            
                    
                    环境搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2.2" data-path="简单语法.html">
            
                <a href="简单语法.html">
            
                    
                    简单语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="函数.html">
            
                <a href="函数.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="进阶篇.html">
            
                <a href="进阶篇.html">
            
                    
                    进阶篇
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="面向对象.html">
            
                <a href="面向对象.html">
            
                    
                    面向对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="泛型.html">
            
                <a href="泛型.html">
            
                    
                    泛型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="枚举.html">
            
                <a href="枚举.html">
            
                    
                    枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="库与导入.html">
            
                <a href="库与导入.html">
            
                    
                    库与导入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="异步编程.html">
            
                <a href="异步编程.html">
            
                    
                    异步编程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.5.1" data-path="异步编程之Future.html">
            
                <a href="异步编程之Future.html">
            
                    
                    Future
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.2" data-path="异步编程之Stream.html">
            
                <a href="异步编程之Stream.html">
            
                    
                    Stream
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.3" data-path="异步编程之Isolate.html">
            
                <a href="异步编程之Isolate.html">
            
                    
                    Isolate
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="异常处理.html">
            
                <a href="异常处理.html">
            
                    
                    异常处理与 Zone
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="生成器.html">
            
                <a href="生成器.html">
            
                    
                    生成器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="标准流与文件.html">
            
                <a href="标准流与文件.html">
            
                    
                    标准流与文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="运算符.html">
            
                <a href="运算符.html">
            
                    
                    附：运算符
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="常用标准库.html">
            
                <a href="常用标准库.html">
            
                    
                    常用标准库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="字符串.html">
            
                <a href="字符串.html">
            
                    
                    字符串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="集合.html">
            
                <a href="集合.html">
            
                    
                    集合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="URI处理.html">
            
                <a href="URI处理.html">
            
                    
                    URI处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="日期和时间.html">
            
                <a href="日期和时间.html">
            
                    
                    日期和时间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="环境及外部调用.html">
            
                <a href="环境及外部调用.html">
            
                    
                    环境及外部调用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="其他.html">
            
                <a href="其他.html">
            
                    
                    其他
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="实战篇.html">
            
                <a href="实战篇.html">
            
                    
                    实战篇
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="网络编程.html">
            
                <a href="网络编程.html">
            
                    
                    网络编程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="爬虫实战.html">
            
                <a href="爬虫实战.html">
            
                    
                    爬虫实战
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="HTTP服务器.html">
            
                <a href="HTTP服务器.html">
            
                    
                    HTTP服务器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="WebSocket服务器.html">
            
                <a href="WebSocket服务器.html">
            
                    
                    WebSocket服务器
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    附录
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="dart2.14.html">
            
                <a href="dart2.14.html">
            
                    
                    升级到Dart 2.14
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="http://www.bczl.xyz/" target="blank" class="gitbook-link">
            编程之路
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >简单语法</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><li><span class="title-icon "></span><a href="#&#x7B80;&#x5355;&#x8BED;&#x6CD5;"><b></b>&#x7B80;&#x5355;&#x8BED;&#x6CD5;</a></li><ul><li><span class="title-icon "></span><a href="#&#x4EE3;&#x7801;&#x6CE8;&#x91CA;"><b></b>&#x4EE3;&#x7801;&#x6CE8;&#x91CA;</a></li><li><span class="title-icon "></span><a href="#&#x53D8;&#x91CF;&#x4E0E;&#x5E38;&#x91CF;"><b></b>&#x53D8;&#x91CF;&#x4E0E;&#x5E38;&#x91CF;</a></li><li><span class="title-icon "></span><a href="#&#x6570;&#x636E;&#x7C7B;&#x578B;"><b></b>&#x6570;&#x636E;&#x7C7B;&#x578B;</a></li><li><span class="title-icon "></span><a href="#&#x5185;&#x7F6E;&#x7C7B;&#x578B;&#x7684;&#x7B80;&#x5355;&#x4F7F;&#x7528;"><b></b>&#x5185;&#x7F6E;&#x7C7B;&#x578B;&#x7684;&#x7B80;&#x5355;&#x4F7F;&#x7528;</a></li><li><span class="title-icon "></span><a href="#&#x903B;&#x8F91;&#x5206;&#x652F;&#x4E0E;&#x5FAA;&#x73AF;"><b></b>&#x903B;&#x8F91;&#x5206;&#x652F;&#x4E0E;&#x5FAA;&#x73AF;</a></li></ul></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><!-- ex_nolevel -->
<h2 id="&#x7B80;&#x5355;&#x8BED;&#x6CD5;"><a name="&#x7B80;&#x5355;&#x8BED;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x7B80;&#x5355;&#x8BED;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7B80;&#x5355;&#x8BED;&#x6CD5;</h2>
<h3 id="&#x4EE3;&#x7801;&#x6CE8;&#x91CA;"><a name="&#x4EE3;&#x7801;&#x6CE8;&#x91CA;" class="anchor-navigation-ex-anchor" href="#&#x4EE3;&#x7801;&#x6CE8;&#x91CA;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4EE3;&#x7801;&#x6CE8;&#x91CA;</h3>
<p>Dart&#x4E2D;&#x7684;&#x4EE3;&#x7801;&#x6CE8;&#x91CA;&#x57FA;&#x672C;&#x4E0E;Java&#x8BED;&#x8A00;&#x76F8;&#x540C;</p>
<pre><code class="lang-dart"><span class="hljs-comment">// &#x5355;&#x884C;&#x6CE8;&#x91CA;</span>

<span class="hljs-comment">/*
 * &#x591A;&#x884C;&#x6CE8;&#x91CA;
 */</span>

<span class="hljs-comment"><span class="markdown">/**
 * &#x6587;&#x6863;&#x6CE8;&#x91CA;
 */</span></span>

<span class="hljs-comment"><span class="markdown">/// &#x4F7F;&#x7528;&#x4E09;&#x4E2A;&#x659C;&#x6760;&#x5F00;&#x5934;</span></span>
<span class="hljs-comment"><span class="markdown">/// &#x8FD9;&#x662F;Dart&#x7279;&#x6709;&#x7684;&#x6587;&#x6863;&#x6CE8;&#x91CA;</span></span>
</code></pre>
<h3 id="&#x53D8;&#x91CF;&#x4E0E;&#x5E38;&#x91CF;"><a name="&#x53D8;&#x91CF;&#x4E0E;&#x5E38;&#x91CF;" class="anchor-navigation-ex-anchor" href="#&#x53D8;&#x91CF;&#x4E0E;&#x5E38;&#x91CF;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x53D8;&#x91CF;&#x4E0E;&#x5E38;&#x91CF;</h3>
<h4 id="&#x5B9A;&#x4E49;&#x53D8;&#x91CF;"><a name="&#x5B9A;&#x4E49;&#x53D8;&#x91CF;" class="anchor-navigation-ex-anchor" href="#&#x5B9A;&#x4E49;&#x53D8;&#x91CF;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B9A;&#x4E49;&#x53D8;&#x91CF;</h4>
<p>Dart&#x4E2D;&#x5B9A;&#x4E49;&#x53D8;&#x91CF;&#x6709;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#xFF0C;&#x4E00;&#x79CD;&#x662F;&#x9759;&#x6001;&#x7C7B;&#x578B;&#x8BED;&#x8A00;&#x5E38;&#x7528;&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x663E;&#x5F0F;&#x6307;&#x5B9A;&#x53D8;&#x91CF;&#x7C7B;&#x578B;&#xFF0C;&#x53E6;&#x4E00;&#x79CD;&#x5219;&#x662F;&#x52A8;&#x6001;&#x8BED;&#x8A00;&#x7684;&#x5E38;&#x7528;&#x65B9;&#x5F0F;&#xFF0C;&#x4E0D;&#x6307;&#x5B9A;&#x7C7B;&#x578B;&#xFF0C;&#x7531;vm&#x81EA;&#x52A8;&#x63A8;&#x65AD;&#x3002;</p>
<pre><code class="lang-dart"><span class="hljs-comment">// 1.&#x901A;&#x8FC7;&#x663E;&#x5F0F;&#x6307;&#x5B9A;&#x7C7B;&#x578B;&#x6765;&#x5B9A;&#x4E49;&#x53D8;&#x91CF;</span>
<span class="hljs-built_in">String</span> name = <span class="hljs-string">&quot;&#x5F20;&#x4E09;&quot;</span>;
<span class="hljs-built_in">num</span> age = <span class="hljs-number">18</span>;

<span class="hljs-comment">// 2.&#x4F7F;&#x7528;&#x5173;&#x952E;&#x5B57;var&#xFF0C;&#x4E0D;&#x6307;&#x5B9A;&#x7C7B;&#x578B;</span>
<span class="hljs-keyword">var</span> address = <span class="hljs-string">&quot;&#x6DF1;&#x5357;&#x5927;&#x9053;&quot;</span>;
<span class="hljs-keyword">var</span> id = <span class="hljs-number">100</span>;

<span class="hljs-comment">/* &#x4F7F;&#x7528;var&#x5B9A;&#x4E49;&#x53D8;&#x91CF;&#xFF0C;&#x5373;&#x4F7F;&#x672A;&#x663E;&#x5F0F;&#x6307;&#x5B9A;&#x7C7B;&#x578B;&#xFF0C;&#x4E00;&#x65E6;&#x8D4B;&#x503C;&#x540E;&#x7C7B;&#x578B;&#x5C31;&#x88AB;&#x56FA;&#x5B9A;
 * &#x56E0;&#x6B64;&#x4F7F;&#x7528;var&#x5B9A;&#x4E49;&#x7684;&#x53D8;&#x91CF;&#x4E0D;&#x80FD;&#x6539;&#x53D8;&#x6570;&#x636E;&#x7C7B;&#x578B;
 */</span>
<span class="hljs-keyword">var</span> number = <span class="hljs-number">19</span>;
<span class="hljs-comment">// &#x4EE5;&#x4E0B;&#x4EE3;&#x7801;&#x9519;&#x8BEF;&#xFF0C;&#x65E0;&#x6CD5;&#x8FD0;&#x884C;&#xFF0C;number&#x53D8;&#x91CF;&#x5DF2;&#x786E;&#x5B9A;&#x4E3A;int&#x7C7B;&#x578B;</span>
number = <span class="hljs-string">&quot;2019&quot;</span>;
</code></pre>
<p>&#x5982;&#x60F3;&#x52A8;&#x6001;&#x6539;&#x53D8;&#x53D8;&#x91CF;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF0C;&#x5E94;&#x5F53;&#x4F7F;&#x7528;<code>dynamic</code>&#x6216;<code>Object</code>&#x6765;&#x5B9A;&#x4E49;&#x53D8;&#x91CF;&#x3002;</p>
<pre><code class="lang-dart"><span class="hljs-comment">// dynamic&#x58F0;&#x660E;&#x53D8;&#x91CF;</span>
<span class="hljs-keyword">dynamic</span> var1 = <span class="hljs-string">&quot;hello&quot;</span>;
var1 = <span class="hljs-number">19</span>;
<span class="hljs-built_in">print</span>(var1);    <span class="hljs-comment">// 19</span>

<span class="hljs-comment">// Object&#x58F0;&#x660E;&#x53D8;&#x91CF;</span>
<span class="hljs-built_in">Object</span> var2 = <span class="hljs-number">20</span>;
var2 = <span class="hljs-string">&quot;Alice&quot;</span>;
<span class="hljs-built_in">print</span>(var2);    <span class="hljs-comment">// Alice</span>
</code></pre>
<p>&#x5EFA;&#x8BAE;&#x5728;&#x7F16;&#x5199;&#x4EE3;&#x7801;&#x65F6;&#xFF0C;&#x5C3D;&#x53EF;&#x80FD;&#x663E;&#x5F0F;&#x6307;&#x5B9A;&#x53D8;&#x91CF;&#x7C7B;&#x578B;&#xFF0C;&#x8FD9;&#x6837;&#x53EF;&#x4EE5;&#x63D0;&#x5347;&#x4EE3;&#x7801;&#x53EF;&#x8BFB;&#x6027;&#x4E0E;&#x8C03;&#x8BD5;&#x7684;&#x4FBF;&#x5229;&#x6027;&#x3002;</p>
<h4 id="&#x5B9A;&#x4E49;&#x5E38;&#x91CF;"><a name="&#x5B9A;&#x4E49;&#x5E38;&#x91CF;" class="anchor-navigation-ex-anchor" href="#&#x5B9A;&#x4E49;&#x5E38;&#x91CF;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B9A;&#x4E49;&#x5E38;&#x91CF;</h4>
<p>Dart&#x4E2D;&#x5B9A;&#x4E49;&#x5E38;&#x91CF;&#x4E5F;&#x6709;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#xFF0C;&#x4E00;&#x79CD;&#x4F7F;&#x7528;<code>final</code>&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x540C;Java&#x4E2D;&#x7684;&#x7528;&#x6CD5;&#xFF0C; &#x4E00;&#x4E2A; final &#x53D8;&#x91CF;&#x53EA;&#x80FD;&#x8D4B;&#x503C;&#x4E00;&#x6B21;&#xFF1B;&#x53E6;&#x4E00;&#x79CD;&#x662F;Dart&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x4F7F;&#x7528;<code>const</code>&#x5173;&#x952E;&#x5B57;&#x5B9A;&#x4E49;&#x3002;</p>
<pre><code class="lang-dart"><span class="hljs-comment">// 1.&#x4F7F;&#x7528;final&#x5173;&#x952E;&#x5B57;&#x5B9A;&#x4E49;&#x5E38;&#x91CF;</span>
<span class="hljs-keyword">final</span> height = <span class="hljs-number">10</span>;

<span class="hljs-comment">// 2.&#x4F7F;&#x7528;const&#x5173;&#x952E;&#x5B57;&#x5B9A;&#x4E49;&#x5E38;&#x91CF;</span>
<span class="hljs-keyword">const</span> pi = <span class="hljs-number">3.14</span>;
</code></pre>
<p>&#x9700;&#x8981;&#x6CE8;&#x610F;&#xFF0C;<code>final</code>&#x5B9A;&#x4E49;&#x7684;&#x5E38;&#x91CF;&#x662F;&#x8FD0;&#x884C;&#x65F6;&#x5E38;&#x91CF;&#xFF0C;&#x800C;<code>const</code>&#x5E38;&#x91CF;&#x5219;&#x662F;&#x7F16;&#x8BD1;&#x65F6;&#x5E38;&#x91CF;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;<code>final</code>&#x5B9A;&#x4E49;&#x5E38;&#x91CF;&#x65F6;&#xFF0C;&#x5176;&#x503C;&#x53EF;&#x4EE5;&#x662F;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#xFF0C;&#x800C;<code>const</code>&#x5B9A;&#x4E49;&#x7684;&#x5E38;&#x91CF;&#xFF0C;&#x5176;&#x503C;&#x5FC5;&#x987B;&#x662F;&#x4E00;&#x4E2A;&#x5B57;&#x9762;&#x5E38;&#x91CF;&#x503C;&#x3002;</p>
<pre><code class="lang-dart"><span class="hljs-keyword">final</span> time = <span class="hljs-keyword">new</span> <span class="hljs-built_in">DateTime</span>.now(); <span class="hljs-comment">// &#x6B63;&#x786E;</span>
<span class="hljs-keyword">const</span> time = <span class="hljs-keyword">new</span> <span class="hljs-built_in">DateTime</span>.now(); <span class="hljs-comment">// &#x9519;&#x8BEF;</span>


<span class="hljs-keyword">const</span> list = <span class="hljs-keyword">const</span>[<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>];       <span class="hljs-comment">// &#x6B63;&#x786E;</span>
<span class="hljs-keyword">const</span> list = [<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>];            <span class="hljs-comment">// &#x9519;&#x8BEF;</span>
</code></pre>
<h3 id="&#x6570;&#x636E;&#x7C7B;&#x578B;"><a name="&#x6570;&#x636E;&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x636E;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6570;&#x636E;&#x7C7B;&#x578B;</h3>
<p><img src="https://img-blog.csdnimg.cn/20190323004151710.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9hcmN0aWNmb3guYmxvZy5jc2RuLm5ldA==,size_16,color_FFFFFF,t_70" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<blockquote>
<p>&#x5728;Dart&#x4E2D;&#xFF0C;&#x6240;&#x6709;&#x80FD;&#x591F;&#x4F7F;&#x7528;&#x53D8;&#x91CF;&#x5F15;&#x7528;&#x7684;&#x90FD;&#x662F;&#x5BF9;&#x8C61;&#xFF0C;&#x6BCF;&#x4E2A;&#x5BF9;&#x8C61;&#x90FD;&#x662F;&#x4E00;&#x4E2A;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;&#x3002;&#x6570;&#x5B57;&#x3001;&#x51FD;&#x6570;&#x548C; <code>null</code> &#x4E5F;&#x90FD;&#x662F;&#x5BF9;&#x8C61;&#x3002;&#x6240;&#x6709;&#x7684;&#x5BF9;&#x8C61;&#x90FD;&#x7EE7;&#x627F;&#x4E8E;Object&#x7C7B;&#x3002;</p>
</blockquote>
<p>&#x8981;&#x6CE8;&#x610F;&#xFF0C;&#x6CA1;&#x6709;&#x521D;&#x59CB;&#x5316;&#x7684;&#x53D8;&#x91CF;&#x9ED8;&#x8BA4;&#x503C;&#x4E3A; <code>null</code>&#x3002;&#x6570;&#x503C;&#x7C7B;&#x578B;&#x53D8;&#x91CF;&#x7684;&#x9ED8;&#x8BA4;&#x503C;&#x4E5F;&#x662F; <code>null</code>&#x3002;</p>
<p>&#x6570;&#x503C;&#x7C7B;&#x578B;<code>num</code>&#x6709;&#x4E24;&#x4E2A;&#x5177;&#x4F53;&#x5B50;&#x7C7B;&#xFF0C;&#x5206;&#x522B;&#x4E3A;<code>int</code>&#x548C;<code>double</code>&#xFF0C;&#x5176;&#x4E2D;<code>int</code>&#x4E3A;&#x6574;&#x6570;&#x503C;&#xFF0C;&#x8303;&#x56F4;&#x662F;<code>-2^53</code>&#x81F3;<code>2^53</code>&#x4E4B;&#x95F4;&#xFF1B;<code>double</code>&#x5219;&#x662F;64&#x4F4D;&#x7684;&#x53CC;&#x7CBE;&#x5EA6;&#x6D6E;&#x70B9;&#x6570;&#x3002;</p>
<h3 id="&#x5185;&#x7F6E;&#x7C7B;&#x578B;&#x7684;&#x7B80;&#x5355;&#x4F7F;&#x7528;"><a name="&#x5185;&#x7F6E;&#x7C7B;&#x578B;&#x7684;&#x7B80;&#x5355;&#x4F7F;&#x7528;" class="anchor-navigation-ex-anchor" href="#&#x5185;&#x7F6E;&#x7C7B;&#x578B;&#x7684;&#x7B80;&#x5355;&#x4F7F;&#x7528;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5185;&#x7F6E;&#x7C7B;&#x578B;&#x7684;&#x7B80;&#x5355;&#x4F7F;&#x7528;</h3>
<h4 id="&#x6570;&#x503C;&#x7C7B;&#x578B;"><a name="&#x6570;&#x503C;&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x503C;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6570;&#x503C;&#x7C7B;&#x578B;</h4>
<pre><code class="lang-dart"><span class="hljs-comment">// String &#x8F6C; int</span>
<span class="hljs-keyword">var</span> one = <span class="hljs-built_in">int</span>.parse(<span class="hljs-string">&apos;1&apos;</span>);

<span class="hljs-comment">// String &#x8F6C; double</span>
<span class="hljs-keyword">var</span> onePointOne = <span class="hljs-built_in">double</span>.parse(<span class="hljs-string">&apos;1.1&apos;</span>);

<span class="hljs-comment">// int &#x8F6C; String</span>
<span class="hljs-built_in">String</span> oneAsStr = <span class="hljs-number">1.</span>toString();

<span class="hljs-comment">// double &#x8F6C; String</span>
<span class="hljs-built_in">String</span> piAsStr = <span class="hljs-number">3.14159</span>.toStringAsFixed(<span class="hljs-number">2</span>); <span class="hljs-comment">// &#x4FDD;&#x7559;&#x4E24;&#x4F4D; &apos;3.14&apos;</span>

<span class="hljs-comment">// Dart&#x4E5F;&#x652F;&#x6301;&#x6574;&#x6570;&#x4F4D;&#x64CD;&#x4F5C;&#xFF0C;&lt;&lt;&#x3001; &gt;&gt;&#x3001;&amp;&#x3001;|</span>
<span class="hljs-built_in">print</span>((<span class="hljs-number">3</span> &lt;&lt; <span class="hljs-number">1</span>) == <span class="hljs-number">6</span>);  <span class="hljs-comment">// 0011 &lt;&lt; 1 == 0110</span>
<span class="hljs-built_in">print</span>((<span class="hljs-number">3</span> &gt;&gt; <span class="hljs-number">1</span>) == <span class="hljs-number">1</span>);  <span class="hljs-comment">// 0011 &gt;&gt; 1 == 0001</span>
<span class="hljs-built_in">print</span>((<span class="hljs-number">3</span> | <span class="hljs-number">4</span>)  == <span class="hljs-number">7</span>);  <span class="hljs-comment">// 0011 | 0100 == 0111</span>
</code></pre>
<h4 id="&#x5B57;&#x7B26;&#x4E32;"><a name="&#x5B57;&#x7B26;&#x4E32;" class="anchor-navigation-ex-anchor" href="#&#x5B57;&#x7B26;&#x4E32;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B57;&#x7B26;&#x4E32;</h4>
<blockquote>
<p>&#x503C;&#x5F97;&#x4E00;&#x63D0;&#x7684;&#x662F;&#xFF0C;Dart&#x4E2D;&#x63D0;&#x4F9B;&#x7684;&#x5B57;&#x7B26;&#x4E32;<code>&#x63D2;&#x503C;&#x8868;&#x8FBE;&#x5F0F;</code>&#x4F7F;&#x5B57;&#x7B26;&#x4E32;&#x683C;&#x5F0F;&#x5316;&#x53D8;&#x5F97;&#x5F02;&#x5E38;&#x65B9;&#x4FBF;&#x3002;</p>
</blockquote>
<pre><code class="lang-dart"><span class="hljs-comment">// 1.Dart&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5355;&#x5F15;&#x53F7;&#x6216;&#x53CC;&#x5F15;&#x53F7;&#x6765;&#x521B;&#x5EFA;&#x5B57;&#x7B26;&#x4E32;</span>
<span class="hljs-keyword">var</span> s1 = <span class="hljs-string">&quot;hello&quot;</span>;
<span class="hljs-keyword">var</span> s2 = <span class="hljs-string">&apos;world&apos;</span>;

<span class="hljs-comment">// 2.&#x7C7B;&#x4F3C;Python&#xFF0C;Dart&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4E09;&#x5F15;&#x53F7;&#x6765;&#x521B;&#x5EFA;&#x4FDD;&#x7559;&#x539F;&#x6709;&#x683C;&#x5F0F;&#x7684;&#x591A;&#x884C;&#x5B57;&#x7B26;&#x4E32;</span>
<span class="hljs-keyword">var</span> multiLine1 = <span class="hljs-string">&quot;&quot;&quot;&#x4F60;&#x53EF;&#x4EE5;&#x50CF;&#x8FD9;&#x6837;&#xFF0C;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;
&#x5305;&#x542B;&#x4E86;&#x591A;&#x884C;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x5185;&#x5BB9;
&quot;&quot;&quot;</span>;

<span class="hljs-keyword">var</span> multiLine2 = <span class="hljs-string">&apos;&apos;&apos;&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4E09;&#x4E2A;&#x5355;&#x5F15;&#x53F7;&#xFF0C;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;
&#x5305;&#x542B;&#x4E86;&#x591A;&#x884C;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x5185;&#x5BB9;
&apos;&apos;&apos;</span>;

<span class="hljs-comment">// 3.&#x7C7B;&#x4F3C;Python&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x5728;&#x5B57;&#x7B26;&#x4E32;&#x5B57;&#x9762;&#x503C;&#x7684;&#x524D;&#x9762;&#x52A0;&#x4E0A;`r`&#x6765;&#x521B;&#x5EFA;&#x539F;&#x59CB;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x5219;&#x8BE5;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x7279;&#x6B8A;&#x5B57;&#x7B26;&#x53EF;&#x4EE5;&#x4E0D;&#x7528;&#x8F6C;&#x4E49;</span>
<span class="hljs-keyword">var</span> path = <span class="hljs-string">r&apos;D:\workspace\code&apos;</span>;

<span class="hljs-comment">// 4.Dart&#x652F;&#x6301;&#x4F7F;&#x7528;&quot;+&quot;&#x64CD;&#x4F5C;&#x7B26;&#x62FC;&#x63A5;&#x5B57;&#x7B26;&#x4E32;</span>
<span class="hljs-keyword">var</span> greet = <span class="hljs-string">&quot;hello&quot;</span> + <span class="hljs-string">&quot; world&quot;</span>;

<span class="hljs-comment">// 5.Dart&#x63D0;&#x4F9B;&#x4E86;&#x63D2;&#x503C;&#x8868;&#x8FBE;&#x5F0F;&quot;${}&quot;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x7528;&#x4E8E;&#x62FC;&#x63A5;&#x5B57;&#x7B26;&#x4E32;</span>
<span class="hljs-keyword">var</span> name = <span class="hljs-string">&quot;&#x738B;&#x4E94;&quot;</span>;
<span class="hljs-keyword">var</span> aStr = <span class="hljs-string">&quot;hello,<span class="hljs-subst">${name}</span>&quot;</span>;
<span class="hljs-built_in">print</span>(aStr);    <span class="hljs-comment">// hello,&#x738B;&#x4E94;</span>

<span class="hljs-comment">// &#x5F53;&#x4EC5;&#x53D6;&#x53D8;&#x91CF;&#x503C;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x7701;&#x7565;&#x82B1;&#x62EC;&#x53F7;</span>
<span class="hljs-keyword">var</span> aStr2 = <span class="hljs-string">&quot;hello,$name&quot;</span>; <span class="hljs-comment">// hello,&#x738B;&#x4E94;</span>

<span class="hljs-comment">// &#x5F53;&#x62FC;&#x63A5;&#x7684;&#x662F;&#x4E00;&#x4E2A;&#x8868;&#x8FBE;&#x5F0F;&#x65F6;&#xFF0C;&#x5219;&#x4E0D;&#x80FD;&#x7701;&#x7565;&#x82B1;&#x62EC;&#x53F7;</span>
<span class="hljs-keyword">var</span> str1 = <span class="hljs-string">&quot;link&quot;</span>;
<span class="hljs-keyword">var</span> str2 = <span class="hljs-string">&quot;click <span class="hljs-subst">${str1.toUpperCase()}</span>&quot;</span>;
<span class="hljs-built_in">print</span>(str2);   <span class="hljs-comment">// click LINK</span>

<span class="hljs-comment">// 6. &#x4E0E;Java&#x4E0D;&#x540C;&#xFF0C;Dart&#x4F7F;&#x7528;&quot;==&quot;&#x6765;&#x6BD4;&#x8F83;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x5185;&#x5BB9;</span>
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;hello&quot;</span> == <span class="hljs-string">&quot;world&quot;</span>);
</code></pre>
<h4 id="&#x5E03;&#x5C14;&#x7C7B;&#x578B;"><a name="&#x5E03;&#x5C14;&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x5E03;&#x5C14;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5E03;&#x5C14;&#x7C7B;&#x578B;</h4>
<blockquote>
<p>Dart&#x4E2D;&#x7684;&#x5E03;&#x5C14;&#x7C7B;&#x578B;&#x7528;&#x6CD5;&#x540C;Java&#xFF0C;&#x4EC5;&#x6709;<code>false</code>&#x3001;<code>true</code>&#x4E24;&#x4E2A;&#x503C;&#xFF0C;&#x4E0D;&#x80FD;&#x4F7F;&#x7528;0&#x3001;&#x975E;0&#x6216;&#x8005;<code>null</code>&#x3001;&#x975E;<code>null</code>&#x6765;&#x8868;&#x8FBE;<code>false</code>&#x548C;<code>true</code>&#x3002;&#x4E0E;Java&#x4E0D;&#x540C;&#x7684;&#x662F;&#xFF0C;&#x5E03;&#x5C14;&#x7C7B;&#x578B;&#x7684;&#x9ED8;&#x8BA4;&#x503C;&#x4E3A;<code>null</code></p>
</blockquote>
<pre><code class="lang-dart"><span class="hljs-built_in">bool</span> flags;
<span class="hljs-built_in">print</span>(flags);    <span class="hljs-comment">// null</span>
</code></pre>
<h4 id="&#x5217;&#x8868;"><a name="&#x5217;&#x8868;" class="anchor-navigation-ex-anchor" href="#&#x5217;&#x8868;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5217;&#x8868;</h4>
<p>Dart&#x4E2D;&#x5217;&#x8868;&#x64CD;&#x4F5C;&#x4E0E;JavaScript&#x4E2D;&#x7684;&#x6570;&#x7EC4;&#x76F8;&#x4F3C;&#x3002;</p>
<pre><code class="lang-dart"><span class="hljs-comment">// &#x521B;&#x5EFA;&#x5217;&#x8868;</span>
<span class="hljs-keyword">var</span> list = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
<span class="hljs-comment">// &#x4E0B;&#x6807;&#x4ECE;0&#x5F00;&#x59CB;&#x3002;&#x4F7F;&#x7528;length&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;list&#x7684;&#x957F;&#x5EA6;</span>
<span class="hljs-built_in">print</span>(list[<span class="hljs-number">0</span>]);
<span class="hljs-built_in">print</span>(list.length);

<span class="hljs-comment">// &#x53EF;&#x4EE5;&#x4F7F;&#x7528;add&#x6DFB;&#x52A0;&#x5143;&#x7D20;</span>
list.add(<span class="hljs-number">5</span>);

<span class="hljs-comment">// &#x53EF;&#x5728;list&#x5B57;&#x9762;&#x91CF;&#x524D;&#x6DFB;&#x52A0;const&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x4E0D;&#x53EF;&#x6539;&#x53D8;&#x7684; &#x5217;&#x8868;&#xFF08;&#x7F16;&#x8BD1;&#x65F6;&#x5E38;&#x91CF;&#xFF09;</span>
<span class="hljs-keyword">var</span> constantList = <span class="hljs-keyword">const</span> [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
constantList[<span class="hljs-number">1</span>] = <span class="hljs-number">1</span>;     <span class="hljs-comment">// &#x62A5;&#x9519;</span>
</code></pre>
<h4 id="&#x6620;&#x5C04;"><a name="&#x6620;&#x5C04;" class="anchor-navigation-ex-anchor" href="#&#x6620;&#x5C04;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6620;&#x5C04;</h4>
<p>&#x53C8;&#x79F0;&#x4E3A;&#x5173;&#x8054;&#x6570;&#x7EC4;&#xFF0C;&#x76F8;&#x5F53;&#x4E8E;Java&#x4E2D;&#x7684;<code>HashMap</code></p>
<pre><code class="lang-dart"><span class="hljs-comment">// 1.&#x901A;&#x8FC7;&#x5B57;&#x9762;&#x91CF;&#x521B;&#x5EFA;Map</span>
<span class="hljs-keyword">var</span> gifts = {
  <span class="hljs-string">&apos;first&apos;</span> : <span class="hljs-string">&apos;partridge&apos;</span>,
  <span class="hljs-string">&apos;second&apos;</span>: <span class="hljs-string">&apos;turtledoves&apos;</span>,
  <span class="hljs-string">&apos;fifth&apos;</span> : <span class="hljs-string">&apos;golden rings&apos;</span>
};

<span class="hljs-comment">// 2.&#x4F7F;&#x7528;Map&#x7C7B;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;</span>
<span class="hljs-keyword">var</span> pic = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Map</span>();
<span class="hljs-comment">// &#x5F80;Map&#x4E2D;&#x6DFB;&#x52A0;&#x952E;&#x503C;&#x5BF9;</span>
pic[<span class="hljs-string">&apos;first&apos;</span>] = <span class="hljs-string">&apos;partridge&apos;</span>;
pic[<span class="hljs-string">&apos;second&apos;</span>] = <span class="hljs-string">&apos;turtledoves&apos;</span>;
pic[<span class="hljs-string">&apos;fifth&apos;</span>] = <span class="hljs-string">&apos;golden rings&apos;</span>;

<span class="hljs-comment">// 3.&#x83B7;&#x53D6;Map&#x7684;&#x957F;&#x5EA6;</span>
<span class="hljs-built_in">print</span>(pic.length);

<span class="hljs-comment">// 4.&#x67E5;&#x627E;&#x952E;&#x5BF9;&#x5E94;&#x7684;&#x503C;</span>
pirnt(pic[<span class="hljs-string">&quot;first&quot;</span>]);
<span class="hljs-built_in">print</span>(pic[<span class="hljs-string">&quot;four&quot;</span>]);    <span class="hljs-comment">// &#x952E;&#x4E0D;&#x5B58;&#x5728;&#x5219;&#x8FD4;&#x56DE; null</span>
</code></pre>
<h3 id="&#x903B;&#x8F91;&#x5206;&#x652F;&#x4E0E;&#x5FAA;&#x73AF;"><a name="&#x903B;&#x8F91;&#x5206;&#x652F;&#x4E0E;&#x5FAA;&#x73AF;" class="anchor-navigation-ex-anchor" href="#&#x903B;&#x8F91;&#x5206;&#x652F;&#x4E0E;&#x5FAA;&#x73AF;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x903B;&#x8F91;&#x5206;&#x652F;&#x4E0E;&#x5FAA;&#x73AF;</h3>
<h4 id="&#x6761;&#x4EF6;&#x5206;&#x652F;"><a name="&#x6761;&#x4EF6;&#x5206;&#x652F;" class="anchor-navigation-ex-anchor" href="#&#x6761;&#x4EF6;&#x5206;&#x652F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6761;&#x4EF6;&#x5206;&#x652F;</h4>
<p>Dart&#x4E2D;&#x7684;&#x6761;&#x4EF6;&#x5206;&#x652F;&#x57FA;&#x672C;&#x4E0E;Java&#x76F8;&#x540C;</p>
<p><code>if</code>&#x6761;&#x4EF6;&#x5206;&#x652F;</p>
<pre><code class="lang-dart"><span class="hljs-keyword">if</span>(i &lt; <span class="hljs-number">0</span>){
  <span class="hljs-built_in">print</span>(<span class="hljs-string">&apos;i &lt; 0&apos;</span>);
}<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(i == <span class="hljs-number">0</span>){
  <span class="hljs-built_in">print</span>(<span class="hljs-string">&apos;i = 0&apos;</span>);
} <span class="hljs-keyword">else</span> {
  <span class="hljs-built_in">print</span>(<span class="hljs-string">&apos;i &gt; 0&apos;</span>);
}
</code></pre>
<p><code>switch</code>&#x6761;&#x4EF6;&#x5206;&#x652F;</p>
<pre><code class="lang-dart"><span class="hljs-comment">// &#x5728;switch&#x7684;case&#x4E2D;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x6574;&#x6570;&#x3001;&#x5B57;&#x7B26;&#x4E32;&#x3001;&#x679A;&#x4E3E;&#x7C7B;&#x578B;&#x548C;&#x7F16;&#x8BD1;&#x65F6;&#x5E38;&#x91CF;</span>
<span class="hljs-built_in">String</span> command = <span class="hljs-string">&apos;OPEN&apos;</span>;
<span class="hljs-keyword">switch</span> (command) {
  <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;CLOSED&apos;</span>:
    <span class="hljs-keyword">break</span>;
  <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;OPEN&apos;</span>:
    <span class="hljs-keyword">break</span>;
  <span class="hljs-keyword">default</span>:
    <span class="hljs-built_in">print</span>(<span class="hljs-string">&apos;Default&apos;</span>);
}
</code></pre>
<h4 id="&#x5FAA;&#x73AF;&#x8BED;&#x53E5;"><a name="&#x5FAA;&#x73AF;&#x8BED;&#x53E5;" class="anchor-navigation-ex-anchor" href="#&#x5FAA;&#x73AF;&#x8BED;&#x53E5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5FAA;&#x73AF;&#x8BED;&#x53E5;</h4>
<h5 id="&#x57FA;&#x672C;&#x5FAA;&#x73AF;"><a name="&#x57FA;&#x672C;&#x5FAA;&#x73AF;" class="anchor-navigation-ex-anchor" href="#&#x57FA;&#x672C;&#x5FAA;&#x73AF;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x57FA;&#x672C;&#x5FAA;&#x73AF;</h5>
<p>Dart&#x4E2D;&#x7684;&#x57FA;&#x672C;&#x5FAA;&#x73AF;&#x8BED;&#x53E5;&#x4E0E;Java&#x76F8;&#x540C;</p>
<pre><code class="lang-dart"><span class="hljs-comment">// for&#x5FAA;&#x73AF;</span>
<span class="hljs-keyword">for</span>(<span class="hljs-built_in">int</span> i = <span class="hljs-number">0</span>; i &lt; <span class="hljs-number">9</span>; i++) {
  <span class="hljs-built_in">print</span>(i);
}

<span class="hljs-comment">// while&#x5FAA;&#x73AF;</span>
<span class="hljs-keyword">while</span>(<span class="hljs-keyword">true</span>){
  <span class="hljs-comment">//do something</span>
}

<span class="hljs-comment">// do-while&#x5FAA;&#x73AF;</span>
<span class="hljs-keyword">do</span>{
  <span class="hljs-comment">//do something</span>
} <span class="hljs-keyword">while</span>(<span class="hljs-keyword">true</span>);
</code></pre>
<h5 id="&#x7279;&#x6709;&#x5FAA;&#x73AF;"><a name="&#x7279;&#x6709;&#x5FAA;&#x73AF;" class="anchor-navigation-ex-anchor" href="#&#x7279;&#x6709;&#x5FAA;&#x73AF;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7279;&#x6709;&#x5FAA;&#x73AF;</h5>
<pre><code class="lang-dart"><span class="hljs-keyword">var</span> myList = [<span class="hljs-string">&apos;Java&apos;</span>,<span class="hljs-string">&apos;JavaScript&apos;</span>,<span class="hljs-string">&apos;Dart&apos;</span>];

<span class="hljs-comment">// for...in...&#x5FAA;&#x73AF;&#xFF0C;&#x7C7B;&#x4F3C;Java&#x4E2D;&#x7684;&#x589E;&#x5F3A;for</span>
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> it <span class="hljs-keyword">in</span> myList ){
    <span class="hljs-built_in">print</span>(it);
}

<span class="hljs-comment">// forEach&#x5FAA;&#x73AF;&#x3002;&#x5176;&#x53C2;&#x6570;&#x4E3A;&#x4E00;&#x4E2A;Function&#x5BF9;&#x8C61;&#xFF0C;&#x8FD9;&#x91CC;&#x4F20;&#x5165;&#x4E00;&#x4E2A;&#x533F;&#x540D;&#x51FD;&#x6570;</span>
myList.forEach((<span class="hljs-keyword">var</span> it){
    <span class="hljs-built_in">print</span>(it);
});

<span class="hljs-comment">// &#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x533F;&#x540D;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x7B80;&#x5199;</span>
myList.forEach((it) =&gt; <span class="hljs-built_in">print</span>(it));
</code></pre>
<p>&#x4F7F;&#x7528;&#x5FAA;&#x73AF;&#x904D;&#x5386;Map</p>
<pre><code class="lang-dart"><span class="hljs-keyword">var</span> myMap = {
<span class="hljs-string">&apos;zhangsan&apos;</span>:<span class="hljs-string">&apos;201901&apos;</span>,
<span class="hljs-string">&apos;lisi&apos;</span>:<span class="hljs-string">&apos;201902&apos;</span>,
<span class="hljs-string">&apos;wangwu&apos;</span>:<span class="hljs-string">&apos;201902&apos;</span>
};

<span class="hljs-comment">// forEach&#x904D;&#x5386;Map</span>
myMap.forEach((k, v) =&gt;  <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;$k : $v&quot;</span>));

<span class="hljs-comment">// &#x6839;&#x636E;&#x952E;&#x83B7;&#x53D6;&#x503C;&#x6765;&#x904D;&#x5386;&#x3002;&#x901A;&#x8FC7;keys&#x8FD4;&#x56DE;Map&#x4E2D;&#x6240;&#x6709;&#x952E;&#x7684;&#x96C6;&#x5408;</span>
<span class="hljs-keyword">for</span>(<span class="hljs-keyword">var</span> k <span class="hljs-keyword">in</span> myMap.keys){
    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;$k : <span class="hljs-subst">${myMap[k]}</span>&quot;</span>);
}
</code></pre>
<hr>
<p><strong>&#x516C;&#x4F17;&#x53F7;&#x201C;&#x7F16;&#x7A0B;&#x4E4B;&#x8DEF;&#x4ECE;0&#x5230;1&#x201D;</strong></p>
<p><img src="https://gitee.com/arcticfox1919/ImageHosting/raw/master/img/20190301102949549.jpg" alt="20190301102949549"> </p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; Arcticfox 2020 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x6587;&#x6863;&#x4FEE;&#x8BA2;&#x4E8E;&#xFF1A;
2021-03-18 13:33:36
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="环境搭建.html" class="navigation navigation-prev " aria-label="Previous page: 环境搭建">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="函数.html" class="navigation navigation-next " aria-label="Next page: 函数">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"简单语法","level":"1.2.2","depth":2,"next":{"title":"函数","level":"1.2.3","depth":2,"path":"函数.md","ref":"函数.md","articles":[]},"previous":{"title":"环境搭建","level":"1.2.1","depth":2,"path":"环境搭建.md","ref":"环境搭建.md","articles":[]},"dir":"ltr"},"config":{"plugins":["anchor-navigation-ex","expandable-chapters-small","-lunr","-search","search-pro","-sharing","github","expandable-chapters","pageview-count","theme-comscore","tbfed-pagefooter","popup","custom-favicon"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy Arcticfox 2020","modify_label":"文档修订于：","modify_format":"YYYY-MM-DD HH:mm:ss"},"github":{"url":"https://github.com/arcticfox1919"},"search-pro":{},"popup":{},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":"logo.ico","theme-comscore":{},"pageview-count":{},"custom-favicon":{},"expandable-chapters-small":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"arcticfox","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Dart编程指南","language":"zh-hans","links":{"sidebar":{"主页":"http://www.bczl.xyz/"}},"gitbook":"*"},"file":{"path":"简单语法.md","mtime":"2021-03-18T05:33:36.896Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-10-18T14:58:03.414Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

